package ru.amse.jsynchro.kernel;

import java.io.Serializable;
import java.util.ArrayDeque;
import java.util.Deque;

@SuppressWarnings("serial")
class TreeNode implements Serializable {
    NodeData myData;
    TreeNode myParent;
    TreeNode myLeftChild;
    TreeNode myNext;
    TreeNode(NodeData data, TreeNode parent) {
        myData = data;
        myParent = parent;
    }
    
    /**
     * @return a {@code Deque} presentation of the path of a node.
     * The path is relative of the root folder.
     */
    Deque<String> getPath() {
        Deque<String> result = new ArrayDeque<String>();
        TreeNode cur = myParent;
        result.addFirst(myData.getName());
        while (cur != null) {
            result.addFirst(cur.myData.getName());
            cur = cur.myParent;
        }
        result.removeFirst();
        return result;
    }
    
    void setCompareFileContent(boolean set) {
       myData.setSetCompareFileContent(set);
    }
}